package com.dc.project.entity.vo;

import com.dc.project.entity.po.Template;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * TemplateVo
 *
 * @author chenxueli
 * @date 2025-03-19 10:40:23
 */
@Schema(title = "模板" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class TemplateVo extends BaseVo<Template> implements Serializable {

    @Schema(title = "模板标题")
    private String title;

    @Schema(title = "模板key")
    private String key;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public TemplateVo(@NonNull Template entity) {
        super(entity);
        this.title = entity.getTitle();
        this.key = entity.getKey();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public Template toPo(Template entity) {
        if (entity == null) {
            entity = new Template();
        }
        entity.setTitle(this.title);
        entity.setKey(this.key);
        return super.toPo(entity);
    }

}
